package com.cjw.controller.person;

import com.cjw.config.annotation.OperationLogAnnotation;
import com.cjw.pojo.dto.database.UserDTO;
import com.cjw.pojo.dto.person.UserDetailDTO;
import com.cjw.pojo.query.person.UpdateBaseUser;
import com.cjw.pojo.query.person.UpdateSystemUser;
import com.cjw.service.database.UserService;
import com.cjw.service.person.UserDetailService;
import com.cjw.util.BaseContextHolder;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.Valid;

/**
 * @author cjw
 * @title: OperationAspect
 * @date 2021/9/23
 * @description: 个人信息控制类
 */
@RestController
@RequestMapping("/user/person")
@Api("个人信息资源")
public class PersonUserController {
    @Autowired
    private UserDetailService userDetailService;

    @PostMapping("/findUserDetailDTO")
    @ApiOperation("查询个人详细信息")
    @OperationLogAnnotation(operModul = "个人信息模块-查询个人详细信息",operType = "查看详情",operDesc = "查询")
    public UserDetailDTO findUserDetailDTO() {
        return userDetailService.findUserDetailByUserId();
    }

    @PostMapping("/updateBaseUser")
    @ApiOperation("修改个人基本信息")
    @OperationLogAnnotation(operModul = "个人信息模块-修改个人详细信息",operType = "查看详情",operDesc = "修改")
    public Boolean updateBaseUser(@RequestBody UpdateBaseUser updateBaseUser) {
        return userDetailService.updateBaseUser(updateBaseUser);
    }

    @PostMapping("/updateSystemUser")
    @ApiOperation("修改系统个人信息")
    @OperationLogAnnotation(operModul = "个人信息模块-修改个人系统详细信息",operType = "修改密码",operDesc = "修改")
    public Boolean updateSystemUser(@Valid @RequestBody UpdateSystemUser updateSystemUser) {
        return userDetailService.updateSystemUser(updateSystemUser);
    }

    @PostMapping("/updateIntroduce")
    @ApiOperation("修改个人介绍")
    @OperationLogAnnotation(operModul = "个人信息模块-修改个人详细信息",operType = "修改个人介绍",operDesc = "修改")
    public Boolean updateIntroduce(String introduce) {
        return userDetailService.updateIntroduce(introduce);
    }

    @PostMapping("/uploadHeadImage")
    @ApiOperation("上传头像")
    @OperationLogAnnotation(operModul = "个人信息模块-修改个人头像",operType = "修改头像",operDesc = "修改")
    public String uploadHeadImage(MultipartFile file) {
        return userDetailService.uploadHeadImage(file);
    }

    @PostMapping("/updateHeadImage")
    @ApiOperation("修改头像")
    @OperationLogAnnotation(operModul = "个人信息模块-修改个人头像",operType = "修改头像",operDesc = "修改")
    public String updateHeadImage(String headImage) {
        return userDetailService.updateHeadImage(headImage);
    }


}
